package model.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;

public class SearchResultPage extends BasePage {

    WebElement room;

    //TODO
    public ApartmentDetailsPage clickRoom(String roomName) {
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@title='" + roomName + "']")));
        room = driver.findElement(By.xpath("//*[@title='" + roomName + "']"));

        ((JavascriptExecutor) driver).executeScript("arguments[0].click();", room);
        return new ApartmentDetailsPage(driver);
    }

    public SearchResultPage(WebDriver driver) {
        super(driver);
    }
}
